/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.manage.convertor;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.business.customer.core.domain.operator.CustomerOperator;
import info.peigen.hotpot.business.customer.core.repository.entity.CustomerOperatorEntity;
import info.peigen.hotpot.business.customer.manage.form.CustomerOperatorManageCreateForm;
import info.peigen.hotpot.business.customer.manage.form.CustomerOperatorManageEditForm;
import info.peigen.hotpot.business.customer.manage.form.CustomerOperatorManageSearchForm;
import info.peigen.hotpot.business.customer.manage.info.CustomerOperatorManageInfo;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>(CustomerOperatorManageConvertor)</b>
 * 管理后台领域对象 "客户操作员" 转换器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-09-08
 */
@SuppressWarnings("unused")
@Slf4j
public class CustomerOperatorManageConvertor {
    // ConvertToEntity
    public static CustomerOperatorEntity convertToEntity(CustomerOperator domain) {
        return BeanUtil.copyProperties(domain, CustomerOperatorEntity.class);
    }

    public static CustomerOperatorEntity convertToEntity(CustomerOperatorManageInfo info) {
        return BeanUtil.copyProperties(info, CustomerOperatorEntity.class);
    }

    public static CustomerOperatorEntity convertToEntity(CustomerOperatorManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerOperatorEntity.class);
    }

    public static CustomerOperatorEntity convertToEntity(CustomerOperatorManageCreateForm form) {
        if (form.getOperatorId() == null) {
            form.setOperatorId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerOperatorEntity.class);
    }

    public static CustomerOperatorEntity convertToEntity(CustomerOperatorManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerOperatorEntity.class);
    }

    // ConvertToDomain
    public static CustomerOperator convertToDomain(CustomerOperatorEntity entity) {
        return BeanUtil.copyProperties(entity, CustomerOperator.class);
    }

    public static CustomerOperator convertToDomain(CustomerOperatorManageInfo info) {
        return BeanUtil.copyProperties(info, CustomerOperator.class);
    }

    public static CustomerOperator convertToDomain(CustomerOperatorManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerOperator.class);
    }

    public static CustomerOperator convertToDomain(CustomerOperatorManageCreateForm form) {
        if (form.getOperatorId() == null) {
            form.setOperatorId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerOperator.class);
    }

    public static CustomerOperator convertToDomain(CustomerOperatorManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerOperator.class);
    }

    // convertToInfo
    public static CustomerOperatorManageInfo convertToInfo(CustomerOperator domain) {
        return BeanUtil.copyProperties(domain, CustomerOperatorManageInfo.class);
    }

    public static CustomerOperatorManageInfo convertToInfo(CustomerOperatorEntity entity) {
        return BeanUtil.copyProperties(entity, CustomerOperatorManageInfo.class);
    }

    public static CustomerOperatorManageInfo convertToInfo(CustomerOperatorManageSearchForm form) {
        return BeanUtil.copyProperties(form, CustomerOperatorManageInfo.class);
    }

    public static CustomerOperatorManageInfo convertToInfo(CustomerOperatorManageCreateForm form) {
        if (form.getOperatorId() == null) {
            form.setOperatorId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, CustomerOperatorManageInfo.class);
    }

    public static CustomerOperatorManageInfo convertToInfo(CustomerOperatorManageEditForm form) {
        return BeanUtil.copyProperties(form, CustomerOperatorManageInfo.class);
    }
}